#ifndef _LOCK_QUEUE_HPP
#define _LOCK_QUEUE_HPP

#include <boost/thread.hpp>
#include <queue>
#include <iostream>

template <typename T>
class LockedQueue 
{
public:
    LockedQueue() {}

    void push(T value) 
    {
        boost::unique_lock<boost::mutex> lock(mutex_);
        queue_.push(value);
        lock.unlock();
    }

    T pop() 
    {
        boost::unique_lock<boost::mutex> lock(mutex_);
        T value = queue_.front();
        queue_.pop();
        return value;
    }

    bool empty() const 
    {
        boost::unique_lock<boost::mutex> lock(mutex_);
        return queue_.empty();
    }

private:
    mutable boost::mutex mutex_;
    std::queue<T> queue_;
};

#endif